Skip to content

fix(audit): serialize provider audited attributes in queries#2070

Merged
troian merged 2 commits into
mainfrom
fix/query-provider-audit-attributes
Jun 8, 2026
Merged

fix(audit): serialize provider audited attributes in queries#2070
troian merged 2 commits into
mainfrom
fix/query-provider-audit-attributes

Conversation

@chalabi2
Copy link
Copy Markdown
Contributor

@chalabi2 chalabi2 commented Jun 3, 2026

Description

Closes: akash-network/support#606

Fixes malformed provider audit attribute query responses by decoding stored
audit values as AuditedAttributesStore and reconstructing owner and
auditor from the store key.

The current query implementation decodes audit store values as
AuditedProvider. Since AuditedAttributesStore.attributes and
AuditedProvider.owner are both protobuf field 1, all-provider and
auditor-filtered queries return attribute bytes in the owner field while
auditor and attributes are empty.

Critical files to review:

  • x/audit/keeper/grpc_query.go
  • x/audit/keeper/grpc_query_test.go
  • x/audit/keeper/keeper.go

Validation:

  • GOWORK=off go test ./x/audit/keeper -count=1
  • GOWORK=off go test ./x/audit/... -count=1

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
    • Not applicable: this is not an API or client breaking change.
  • targeted the correct branch (see PR Targeting)
    • Targeting main for normal review and merge.
  • provided a link to the relevant issue or specification
    • No GitHub issue exists; this was reported in Slack on 2026-06-03.
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
    • Not applicable: narrow query serialization fix for an RC branch.
  • included comments for documenting Go code
    • Not applicable: no exported API or new Go doc surface.
  • updated the relevant documentation or specification
    • Not applicable: no documentation/spec change.
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed
    • Pending PR CI.

@chalabi2 chalabi2 requested a review from a team as a code owner June 3, 2026 21:28
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

Walkthrough

The PR fixes malformed provider audit attributes query responses by correcting data unmarshalling alignment. KV values now unmarshal into AuditedAttributesStore with provider identities parsed from keys; AuditorAttributes adds filtered pagination with auditor validation. Test coverage is enhanced with stronger assertions and new query-specific tests.

Changes

Audit Attributes Query and Data Structure Alignment

Layer / File(s) Summary
Data structure unmarshalling in WithProvider iteration
x/audit/keeper/keeper.go
WithProvider now unmarshals KV values into AuditedAttributesStore and constructs AuditedProvider from parsed key data and stored attributes, matching the actual stored data shape.
AllProvidersAttributes and AuditorAttributes query implementations
x/audit/keeper/grpc_query.go
AllProvidersAttributes switches to unmarshalling into AuditedAttributesStore and explicit struct assembly. AuditorAttributes adds filtered pagination with auditor address validation, parsing auditor from keys, and conditional filtering to return only matching results.
Enhanced and new test cases for query functions
x/audit/keeper/grpc_query_test.go
TestGRPCQueryProviders strengthens assertions with expByOwner map and bech32 validation. New TestGRPCQueryAuditorAttributes validates filtered results for a specific auditor across multiple providers. New TestGRPCQueryProviderAttributes verifies single-provider lookups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A query fix hops into view,
With keys parsed fresh and values true,
Attributes unmarshalled just right,
Auditor filters shining bright,
No more malformed data in flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing serialization of provider audited attributes in query responses.
Description check ✅ Passed The description is directly related to the changeset, explaining the serialization bug fix and linking to the issue being resolved.
Linked Issues check ✅ Passed The PR fixes issue #606 by correcting query deserialization to properly return owner, auditor, and attributes fields instead of malformed responses.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the audit query serialization issue: grpc_query.go handles correct deserialization, tests validate the fix, and keeper.go aligns with the new pattern.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/query-provider-audit-attributes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@x/audit/keeper/grpc_query.go`:
- Around line 35-47: AllProvidersAttributes (and similarly AuditorAttributes)
currently paginates over the raw ctx.KVStore(q.skey) and calls ParseIDFromKey
for every key; to avoid future panics and make the scan prefix-safe, wrap the
store with the provider prefix before calling sdkquery.Paginate (use
prefix.NewStore(store, types.PrefixProviderID()) or the equivalent) so only keys
written by ProviderKey(...) are iterated, and keep the existing unmarshalling
into types.AuditedAttributesStore and construction of types.AuditedProvider
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 92f340a7-3cb3-4537-9f10-ef228f78f214

📥 Commits

Reviewing files that changed from the base of the PR and between 499b8ec and f1b6e04.

📒 Files selected for processing (3)
  • x/audit/keeper/grpc_query.go
  • x/audit/keeper/grpc_query_test.go
  • x/audit/keeper/keeper.go
💤 Files with no reviewable changes (1)
  • x/audit/keeper/keeper.go

Comment thread x/audit/keeper/grpc_query.go
@troian troian merged commit 151b989 into main Jun 8, 2026
17 checks passed
@troian troian deleted the fix/query-provider-audit-attributes branch June 8, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix malformed provider audit attributes query responses

3 participants